mui.init();
var main = null;
mui.plusReady(function() {
	
	main = plus.webview.currentWebview().opener();
	//点击“看点什么”出发事件
	var list_card = document.getElementById('list_card');
	var oLi = list_card.getElementsByTagName('li');
	/*alert(oLi.length);*/
	for (var i = 0; i < oLi.length; i++) {
		oLi[i].index = i;
		oLi[i].onclick = function(){
			alert("查看更多");
		}
	}
	//点击“看点什么”出发事件结束
})
mui.getJSON('../../json/benefitPlay.json','',function(data){
	var nearByAtv = [];
	if(data.nearByAtv){
		nearByAtv  = data.nearByAtv;
		var nearAct_bgPic = "";
		var nearAct_title = "";
		var nearAct_address = "";
		var nearAct_sign_up = "";
		var nearAct_time = "";
		var nearByList = "";//定义附近活动变量
		for (var i = 0; i < nearByAtv.length; i++) {
			 nearAct_bgPic = nearByAtv[i].nearImg;
			 nearAct_title = nearByAtv[i].atv_title;
			 alert("nearAct_title----:"+nearAct_title);
			 nearAct_address = nearByAtv[i].atv_address;
			 nearAct_sign_up = nearByAtv[i].atv_signup;
			 nearAct_time = nearByAtv[i].atv_time;
			 console.log("nearAct_bgPic=:"+nearAct_bgPic);
			 console.log("+++:"+nearAct_title);
			 nearByList += del_html_tags($("#nearbyActive").html(),"{{act_bgPic}}",nearAct_bgPic);
			 nearByList = del_html_tags(nearByList,"{{act_time}}",nearAct_time);
			 nearByList = del_html_tags(nearByList,"{{act_address}}",nearAct_address);
			 nearByList = del_html_tags(nearByList,"{{act_sign_up}}",nearAct_sign_up);
			 nearByList = del_html_tags(nearByList,"游戏标题",nearAct_title);
			
		}
		$('.nearby_activ_out_box p').after(nearByList);
	}
	if(data.seeWhat){
		var seeWhat = data.seeWhat;
		var thing_img = "";
		var thing_title = "";
		var thingType_btn = "";
		var thing_viewTime = "";
		var seeWhatList = "";
		for (var i = 0; i < seeWhat.length; i++) {
			thing_img = seeWhat[i].thing_img;
			thing_title = seeWhat[i].thing_title;
			thingType_btn = seeWhat[i].thingType_btn;
			thing_viewTime = seeWhat[i].thing_viewTime;
			seeWhatList += del_html_tags($("#seeWhat").html(),"{{pic}}",thing_img);
			seeWhatList = del_html_tags(seeWhatList,"{{title}}",thing_title);
			seeWhatList = del_html_tags(seeWhatList,"{{name}}",thingType_btn);
			seeWhatList = del_html_tags(seeWhatList,"{{time}}",thing_viewTime);
		}
		$("#list_card ul").append(seeWhatList);
	}
})

//自定义一个方法批量替换制定的字符 
function del_html_tags(str, reallyDo, replaceWith) {
	var e = new RegExp(reallyDo, "g"); //参数 reallyDo 是一个字符串，指定了正则表达式的模式或其他正则表达式,参数 "g" 是一个可选的字符串，包含属性 "g"、"i" 和 "m"，分别用于指定全局匹配、区分大小写的匹配和多行匹配
	words = str.replace(e, replaceWith); //str里的e换做replaceWith
	return words;
}